package com.wd.live.view;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.wd.live.R;
import com.wd.live.base.BaseActivity;
import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.QMBean;
import com.wd.live.databinding.ActivityQianMingBinding;
import com.wd.live.model.utils.ToastFormat;
import com.wd.live.viewmodel.QianMingViewModel;

public class QianMingActivity extends BaseActivity<QianMingViewModel, ActivityQianMingBinding> {


    @Override
    protected void initData() {
        Intent intent = getIntent();
        String qm = intent.getStringExtra("QM");
        databind.userQM3.setText(qm);
        databind.xinFan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        databind.overQianMing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String userQm = databind.userQM3.getText().toString();
                if(userQm.length()<0||userQm.equals("")){
                    ToastFormat.setText("没有设置签名啊(；´д｀)ゞ");
                    ToastFormat.show();
                }else{
                    viewmodel.getList(databind.userQM3.getText().toString()).observe(QianMingActivity.this, new Observer<QMBean>() {
                        @Override
                        public void onChanged(QMBean qmBean) {
                            ToastFormat.setText(qmBean.getMessage());
                            ToastFormat.show();
                            if(qmBean.getStatus().equals("0000")){
                                finish();
                            }
                        }
                    });
                }
            }
        });
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_qian_ming;
    }

    @Override
    public void onChanged(Object o) {

    }
}